package com.example.other.mapper;

import com.example.other.domain.Chat;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.other.domain.UsersInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author Limhuang
* @description 针对表【chat】的数据库操作Mapper
* @createDate 2024-07-09 10:53:21
* @Entity com.example.other.domain.Chat
*/
public interface ChatMapper extends BaseMapper<Chat> {
    @Select("SELECT * FROM users_info WHERE sys_user_id in (SELECT cos_id FROM chat WHERE doctor_id=${doctorId} GROUP BY cos_id)")
    List<UsersInfo> getChatedUsersByDoctorId(@Param("doctorId") Integer doctorId);

    @Select("SELECT * FROM chat WHERE doctor_id=${doctorId} AND cos_id=${userId} ORDER BY id")
    List<Chat> getChatListByDoctorIdAndUserId(@Param("doctorId") Integer doctorId,@Param("userId") Integer userId);

    @Select("SELECT * FROM doctor_users_info WHERE sys_user_id in (SELECT doctor_id FROM chat WHERE cos_id=${cosId} GROUP BY cos_id)")
    List<UsersInfo> getChatedUsersByCosId(@Param("cosId") Integer cosId);
}





